package de.homer.server.setup;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import de.homer.core.user.domain.User;
import de.homer.persistence.user.UserRepository;

/**
 * {@link InitializingBean} to setup some data in the Repositories.
 * 
 * @author André Stannek
 * 
 */
@Component
public class DataSetup implements InitializingBean {

	/**
	 * 
	 */
	@Autowired
	private UserRepository repo;

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
	 */
	@Override
	public final void afterPropertiesSet() throws Exception {
		User admin = new User();
		admin.setUsername("admin");
		admin.setPassword("21232f297a57a5a743894a0e4a801fc3");
		repo.merge(admin);
		User user = new User();
		user.setUsername("user");
		user.setPassword("ee11cbb19052e40b07aac0ca060c23ee");
		repo.merge(user);
	}
}
